package com.yezao.baselib.notification;

import android.app.NotificationManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Build;

import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationManagerCompat;

/**
* 作者：zhuxiaolong
* 时间：2021/3/18 15:40
*
**/
public class NotificationUtils {


    @RequiresApi(api = Build.VERSION_CODES.Q)
    public static boolean canNotifyAsPackage(Context context){
        ApplicationInfo applicationInfo = context.getApplicationInfo();
        NotificationManager managerService= (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

        return managerService.canNotifyAsPackage(applicationInfo.packageName);

    }
    public static boolean checkPermission(Context context){
        PackageManager packageManager = context.getPackageManager();
        ApplicationInfo applicationInfo = context.getApplicationInfo();


        NotificationManagerCompat manager = NotificationManagerCompat.from(context);



        return manager.areNotificationsEnabled();
    }
    private static boolean checkPermissionV19(){
        return false;
    }



}
